package cn.bonoon.controllers.fmm;
//package cn.bonoon.controllers.account;
//
//import static org.springframework.web.bind.annotation.RequestMethod.GET;
//import static org.springframework.web.bind.annotation.RequestMethod.POST;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.servlet.ModelAndView;
//
//import cn.bonoon.core.plugins.AccountService;
//import cn.bonoon.core.plugins.GroupService;
//import cn.bonoon.core.plugins.RoleService;
//import cn.bonoon.entities.GroupEntity;
//import cn.bonoon.kernel.web.controllers.AbstractController;
//import cn.bonoon.kernel.web.models.DialogModel;
//import cn.bonoon.kernel.web.models.JsonResult;
//
//@Controller
//@RequestMapping("s/sys/group")
//public class GroupAssignController extends AbstractController{
//
//	@Autowired
//	private RoleService roleService;
//	@Autowired
//	private GroupService groupService;
//	
//	@Autowired
//	private AccountService accountService;
//
//	@RequestMapping(value = "!{mid}/roles.do", method = { POST, GET })
//	public ModelAndView roles(HttpServletRequest request, 
//			@PathVariable("mid") String mid, 
//			@RequestParam("id") Long id, 
//			@RequestParam("gridid") String gridid) {
//		
//		DialogModel model = new DialogModel(mid, request);
//		model.addForm(id);
//		model.addObject("gridid", gridid);
//		model.addObject("id", id);
//		try{
//			GroupEntity group = groupService.get(id);
//			model.addObject("name", group.getName());
//			
//			// 超级管理员可以分配所有的角色，一般的管理员只允许分配由他创建的那些角色
//			model.addObject("roles", roleService.roles(group));
//		}catch (Exception e) {
//			log(e);
//		}
//		return model.execute("sys/account/group-roles");
//	}
//
//	@ResponseBody
//	@RequestMapping(value = "!{mid}/role!save.b", method = POST)
//	public final JsonResult assign(HttpServletRequest request, 
//			//@PathVariable("mid") String mid, 
//			@RequestParam("id") final Long id, 
//			@RequestParam("ids") Long[] ids) {
//		try{
//			//Long[] roleIds = StringHelper.toLongArray(roles, ",");
//			roleService.saveGroupRoles(getUser(), id, ids);
//			return JsonResult.result();
//		}catch (Exception e) {
//			return JsonResult.error(e);
//		}
//	}
//
//}
